package com.hurui.xiaoming.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.hurui.xiaoming.R;
import com.hurui.xiaoming.bean.Li_profit_Result;
import com.hurui.xiaoming.utils.TimeUtils;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * Created by hurui on 2017/7/21.
 */

public class ProfitAdapter extends RecyclerView.Adapter<ProfitAdapter.ProfitHolder> {
    Context context ;
    List<Li_profit_Result.DataBean> lists ;
    public ProfitAdapter(Context mContext){
        this.context = mContext ;
        lists=new ArrayList<>();
    }
    public void notifyData(List<Li_profit_Result.DataBean> lists){

        this.lists.addAll(lists);
        notifyDataSetChanged();

    }
    @Override
    public ProfitHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View item = LayoutInflater.from(context).inflate(R.layout.profit_item , parent ,false);
        Log.e("ccc", "onCreateViewHolder: ");
        return new ProfitHolder(item);
    }

    @Override
    public void onBindViewHolder(ProfitHolder holder, int position) {
           Li_profit_Result.DataBean dataBean = lists.get(position);

           holder.profit_info.setText("客户【"+dataBean.getName()+"】借款"+dataBean.getOi_jkprice()+"，分期"+dataBean.getOi_jkloans()+"期");
           holder.profit_money.setText(dataBean.getPl_price());
           holder.profit_time.setText(TimeUtils.getTime(new Date()));


    }


    @Override
    public int getItemCount() {
        return lists.size()!=0 ? lists.size():0;
    }

    public class ProfitHolder extends RecyclerView.ViewHolder{

        public   TextView profit_info,profit_time,profit_money;

        public ProfitHolder(View itemView) {
            super(itemView);
            profit_info = ((TextView) itemView.findViewById(R.id.profit_info_tv));
            profit_money = ((TextView) itemView.findViewById(R.id.profit_money_tv));
            profit_time = ((TextView) itemView.findViewById(R.id.profit_time_tv));

        }
    }
}
